﻿using System;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Activation;
using System.Collections.Generic;
using System.Text;
using DiscoveryLogic.DataServices.DataObjects;
using DiscoveryLogic.DataServices.DataObjects.Entities;
using SilverlightFX.Services;

namespace DiscoveryLogic.DataServices
{
    [ServiceContract(Namespace = "")]
    [AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
    public class SearchHistory : CompletionService<string>
    {
        [OperationContract]
        public void SaveSearchHistory(EntityType entityType, string fieldName, string query)
        {
            // Add your operation implementation here
            return;
        }

        #region Overrides of CompletionService<string>
        [OperationContract]
        protected override IEnumerable<string> GetCompletionItems(string prefix)
        {
            List<string> orgNames = new List<string>();
            orgNames.Add("Johns Hopkins University");
            orgNames.Add("Harvard University");
            orgNames.Add("Yale University");
            orgNames.Add("Stanford University");
            orgNames.Add("Washington University");
            orgNames.Add("University of Pennsylvania");
            orgNames.Add("University of Maryland");

            IEnumerable<string> matchedNames =
                from c in orgNames
                where c.StartsWith(prefix, StringComparison.OrdinalIgnoreCase)
                select c;
            return matchedNames.ToList();
        }

        #endregion
    }
}
